package com.arvin.skin;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import com.arvin.skin.core.support.SkinViewSupport;
import com.arvin.skin.core.utils.SkinResources;

public class CircleView extends View implements SkinViewSupport{
    private int circleColor;
    public CircleView(Context context) {
        super(context);
    }

    public CircleView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        TypedArray a = context.obtainStyledAttributes(attrs,R.styleable.CircleView);
        a.getColor(R.styleable.CircleView_circleColor, Color.RED);
        a.recycle();
    }

    public CircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint p = new Paint();
        p.setColor(circleColor);
        canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2,p);
    }

    @Override
    public void applySkin() {
        circleColor = SkinResources.getInstance().getColor(R.color.circle);
        invalidate();
    }
}
